#ifndef __DRIVER_RADAR_H
#define __DRIVER_RADAR_H
#include "py32f0xx_hal.h"
#include <stdint.h>
#include <stdbool.h>

#define KEY_DOWN 0

#define RADAR1_GPIO_CLK_ENABLE __HAL_RCC_GPIOF_CLK_ENABLE
#define RADAR1_GPIO_PORT GPIOF
#define RADAR1_GPIO_PIN GPIO_PIN_1

//
typedef enum
{
    RADAR_OFF,
    RADAR_ON,
    RADAR_IDEL
} RadarState;

//
typedef struct
{
    GPIO_TypeDef *GPIOx;
    uint8_t pin;                                       // io??
    bool (*readIO)(GPIO_TypeDef *GPIOx, uint8_t pin); // 
    uint32_t singalStartTime;
    uint8_t id; 
    RadarState state;
} Radar;

uint32_t millis(void);
bool readRadarPin(GPIO_TypeDef *GPIOx, uint8_t pin);
void radarInit(Radar radars[], uint8_t size);
void radarScan(Radar *radars, uint8_t size);
#endif
